#include "singleton.h"

struct A {
    A(const std::string& x) {
        std::cout << "lvalue" << std::endl;
    }

    A(std::string&& x) {
        std::cout << "rvalue" << std::endl;
    }
};

struct B {
    B(const std::string& x) {
        std::cout << "lvalue" << std::endl;
    }

    B(std::string&& x) {
        std::cout << "rvalue" << std::endl;
    }
};

struct C {
    C(int x, int y) {}
    void fun() {
        std::cout << "fun" << std::endl;
    }
};


int singleton() {
    std::string str = "bb";
    
    A* a = getInstance<A>(str);
    A* b = getInstance<A>(str);
    A* c = getInstance<A>("Hello World");
    printf("%p, %p, %p\n", a, b, c);

    destory<A>();
    printf("%p, %p, %p\n", a, b, c);  // _instance = nullptr, 但是a,b,c不是

    return 0;
}